$title Leisure model

$ontext
--------------------------------------------------------------------------------
Closed 2x2 economy with taxes in the benchmark and leisure-labour choice.
Laurent Cretegny, CoPS, Monash University, Australia, 2003.
--------------------------------------------------------------------------------
$offtext

$set path d:\prof\research\mpsge\mge2gem\examples\mpsge\leisure

sets
  o                 commodity and sector          / agr, ind /
  f                 primary factor                / lab, cap /;

alias(o,s);

parameters
  sam(*,*)          benchmark social accounting matrix
  factor(f,s)       factor demand
  interm(o,s)       intermediate demand
  demand(o)         demand for consumption
  endowdem(f)       endowment demand for household
  endow(f)          endowment
  tr_y(s)           tax revenue on output
  tr_w(f)           tax revenue on endowment
  supply(s)         supply of output
  cons              aggregate consumption
  endowfac(f)       endowment for primary factor (gross of tax)
  endowsup(f)       endowment supply by household
  t_y(s)            tax rate on output
  t_w(f)            tax rate on endowment
  t_y_l(s)          power of tax on output
  t_w_l(f)          power of tax on endowment;

$call gdxxrw i=%path%\leisure.xls o=%path%\leisure.gdx index=declare
$gdxin %path%\leisure.gdx
$load sam = sam
$gdxin

factor(f,s) = sam(f,s);
interm(o,s) = sam(o,s);
demand(o) = sam(o,"ra");
endowdem(f) = sam(f,"ra");
endow(f) = sam("ra",f);
tr_y(s) = sam("ty",s);
tr_w(f) = sam("tw",f);
supply(s) = sum(o, interm(o,s)) + sum(f, factor(f,s)) + tr_y(s);
cons = sum(o, demand(o));
endowfac(f) = endow(f) + tr_w(f) - endowdem(f);
endowsup(f) = endow(f) - endowdem(f);
t_y(s) = tr_y(s) / supply(s);
t_w(f) = tr_w(f) / endowfac(f);
t_y_l(s) = 1 - t_y(s);
t_w_l(f) = 1- t_w(f);

$ontext
$model:leisure

$sectors:
  y(s)              ! production
  u                 ! utility index
  w(f)              ! endowment supply index

$commodities:
  p(o)              ! price of commodity
  pu                ! true cost-of-living index
  pf(f)             ! price of primary factor
  pw(f)             ! price of endowment

$consumers:
  ra                ! representative agent income

$prod:y(s)          s:0.0               va:1.0
  o:p(s)            q:supply(s)         p:t_y_l(s)          a:ra      t:t_y(s)
  i:pf(f)           q:factor(f,s)       va:
  i:p(o)            q:interm(o,s)

$prod:u             s:1.0               esd:1.0
  o:pu              q:(cons+sum(f,endowdem(f)))
  i:pw(f)           q:endowdem(f)
  i:p(o)            q:demand(o)         esd:

$prod:w(f)
  o:pf(f)           q:endowfac(f)       p:t_w_l(f)          a:ra      t:t_w(f)
  i:pw(f)           q:endowsup(f)

$demand:ra
  d:pu              q:(cons+sum(f,endowdem(f)))
  e:pw(f)           q:endow(f)

$report:
  v:r_cons(o)       i:p(o)              prod:u

$offtext
$sysinclude mpsgeset leisure

* Benchmark replication

leisure.iterlim = 0;
$include leisure.gen
solve leisure using mcp;
abort$(abs(leisure.objval) gt 1e-7) "*** leisure does not calibrate ! ***";
leisure.iterlim = 1000;

* Fixation of a numeraire to allow comparison

ra.fx = ra.l;

* Counterfactual : 10% increase in tax rate on labour income

t_w("lab") = t_w("lab") * 1.1;

$include leisure.gen
solve leisure using mcp;

* Results

parameters
  res_com           results by commodity in % change from basis
  res_agg           aggregate results in % change from basis; 

res_com("output",o) = (y.l(o) - 1) * 100;
res_com("cons",o) = (r_cons.l(o)/demand(o) - 1) * 100;
res_com("price",o) = (p.l(o) - 1) * 100;

res_agg("u") = (u.l - 1 ) * 100;
res_agg("pu") = (pu.l - 1 ) * 100;
res_agg("ra_inc") = (ra.l/(cons+sum(f,endowdem(f))) - 1 ) * 100;

option decimals = 6;
display res_com, res_agg;
